<template>
  <el-cascader
    v-model="category"
    :options="categoryTree"
    placeholder="请选择分类"
    class="select-category"
    clearable
    :props="{
      emitPath: false,
      expandTrigger: 'hover',
      label: 'name',
      value: 'id'
    }"
  />
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { categoryTree } from '@/indexDB/initCategory'

const props = defineProps<{
  id: string | number
}>()
const emit = defineEmits(['update:id'])

const category = computed({
  get() {
    return props.id
  },
  set(val) {
    emit('update:id', val)
  }
})
</script>
